exports.ensureAuthenticated   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
nc 2
dl 0
loc 4
rs 10
nop 3
1
// Auth
2
var passport = require('passport')
3
var mongoose = require('mongoose')
4
var User = mongoose.model('User')
5
var local = require('./passport/local')
6
var google = require('./passport/google')
7
8
// serialize sessions
9
passport.serializeUser((user, cb) => cb(null, user.id))
10
passport.deserializeUser((id, cb) => User.load({ criteria: { _id: id } }, cb))
11
12
// use these strategies
13
passport.use(local)
14
passport.use(google)
15
16
exports.ensureAuthenticated = function (req, res, next) {
17
  if (req.isAuthenticated()) { return next() }
18
  res.redirect('/auth/login')
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
19
}
20